<template>
    <div class="item" v-for="(item, index) in list" :key="index">
        <van-checkbox :name="item.id" v-if="show"/>
            <img :src="item.pic" alt="">
            <span class="txt">{{ item.txt }}
                <van-stepper integer class="stepper" v-model="item.num" @change="numchange" :name="item.id"
                    min="0"></van-stepper>
            </span>
            <span class="price">
                ￥{{ item.price }}
            </span>
    </div>
</template>

<script>
import { reactive, toRefs,} from 'vue';
import { useStore } from 'vuex';
export default {

    props: ['show', 'activeIndex', 'list', 'cartdetaillist'],

    setup(props) {
        const store = useStore()
        let data = reactive({
        })
        const numchange = (value, detail) => {
            let allnum = 0
            store.state.cartlist.forEach((itema) => {
                itema.children.forEach((item, index) => {
                    allnum += item.num
                })
                store.commit('addnum', allnum)
            })
        }
        return { ...toRefs(data), store, numchange }
    },
}
</script>

<style lang="scss" scoped>
.van-checkbox {
    margin-right: 20px;
}

.item {
    margin-top: 10px;
    display: flex;
    margin-bottom: 20px;

    img {
        width: 60px;
        height: 60px;
        border-radius: 10px;
        margin-right: 20px;
    }

    .txt {
        width: 80px;
        font-size: 14px;

        .stepper {
            margin-top: 5px;

        }

        :deep .van-stepper__input,
        :deep .van-stepper__minus,
        :deep .van-stepper__plus {
            width: 24px;
            height: 24px;
        }
    }

    .price {
        margin-left: 10px;
        font-size: 14px;
        display: flex;
        flex-direction: column;
        align-items: center;

        :deep .van-icon-add-o:before {
            margin-top: 10px;
        }
    }
}

:deep .van-sidebar-item--select:before {
    background-color: #ffc400;
    width: 3px;
    // top: 9px;
    // left: -2px;
    height: 10px;
    // transform: translateX(20px);
    transition-duration: 0.3s;
    // position: relative;
}

:deep .van-sidebar-item__text {
    font-size: 10px;

}

:deep .van-tree-select__nav {
    padding-left: 35px;
    background: #fff;
}

:deep .van-tree-select {
    margin-top: 0px;
    height: 380px !important;
}

:deep .van-sidebar-item {
    margin-bottom: 7px;
    background-color: #fff;
    overflow: visible;
}

:deep .van-sidebar-item__text {
    font-size: 14px;
}
</style>